import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '../Layout/multipleWidget.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  MyApp({super.key});

  // iOS浅色主题
  final ThemeData kIOSTheme = ThemeData(
      brightness: Brightness.light,//亮色主题
      hintColor: Colors.white,//(按钮)Widget前景色为白色
      primaryColor: Colors.blue,//主题色为蓝色
      iconTheme: const IconThemeData(color: Colors.grey),//icon主题为灰色
      textTheme: const TextTheme(bodyMedium: TextStyle(color: Colors.black))//文本主题为黑色
  );
  // Android深色主题
  final ThemeData kAndroidTheme = ThemeData(
      brightness: Brightness.dark,//深色主题
      hintColor: Colors.black,//(按钮)Widget前景色为黑色
      primaryColor: Colors.cyan,//主题色Wie青色
      iconTheme: const IconThemeData(color: Colors.blue),//icon主题色为蓝色
      textTheme: const TextTheme(bodyMedium: TextStyle(color: Colors.red))//文本主题色为红色
  );

  @override
  Widget build(BuildContext context) {

    // 新建主题
    Theme theme1 = Theme(
        data: ThemeData(iconTheme: const IconThemeData(color: Colors.red)),
        child: const Icon(Icons.favorite)
    );
   // 继承主题
    Theme theme2 = Theme(
        data: Theme.of(context).copyWith(iconTheme: const IconThemeData(color: Colors.green)),
        child: const Icon(Icons.feedback)
    );

    return MaterialApp(
      title: 'Flutter Demo',//标题
      // theme: ThemeData(//设置主题
      //     brightness: Brightness.light,//设置明暗模式为亮色
      //     hintColor: Colors.grey,//(按钮）Widget前景色为黑色
      //     primaryColor: Colors.cyan,//主色调为青色
      //     iconTheme:const IconThemeData(color: Colors.yellow),//设置icon主题色为黄色
      //     textTheme: const TextTheme(bodyMedium: TextStyle(color: Colors.red))//设置文本颜色为红色
      // ),
      theme: defaultTargetPlatform == TargetPlatform.iOS ? kIOSTheme : kAndroidTheme,//根据平台选择不同主题,
      // home: const MyHomePage(title: 'Flutter Demo Home Page'),
      home: Container(
          color: Theme.of(context).primaryColor,//容器背景色复用应用主题色
          child: Text(
            'Text with a background color',
            style: Theme.of(context).textTheme.titleLarge,//Text组件文本样式复用应用文本样式
          )),
    );
  }
}

